<template>
	<view class="container">
		<view class="user-info">
			<image class="avatar" :src="userInfo?.avatar || '/static/logo.svg'"></image>
			<view class="info">
				<view class="nickname">{{userInfo?.mobilePhone ?? '-'}}</view>
				<view class="flex items-center">
					<view class="id">小依ID: {{userInfo?.id ?? '-'}}</view>
					<view class="bg-linear flex items-center tag">
						<image style="width: 20rpx;height: 20rpx;margin-right: 6rpx" src="/static/my/tag.png"></image>
						3个角色
					</view>
				</view>
			</view>
		</view>

		<view class="menu-list">
			<template v-for="(item, index) in menuItems" :key="index">
				<button v-if="item.text === '分享小依'" open-type="share" class="menu-item">
					<image :src="item.icon"></image>
					<text>{{item.text}}</text>
					<image class="arrow" src="/static/arrow.png"></image>
				</button>

				<button v-else-if="item.text === '联系客服'" open-type="contact" class="menu-item">
					<image :src="item.icon"></image>
					<text>{{item.text}}</text>
					<image class="arrow" src="/static/arrow.png"></image>
				</button>

				<view v-else class="menu-item">
					<image :src="item.icon"></image>
					<text>{{item.text}}</text>
					<image class="arrow" src="/static/arrow.png"></image>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: getApp().globalData.userInfo,
				menuItems: [{
						icon: '/static/my/user-shared-line.png',
						text: '分享小依'
					},
					{
						icon: '/static/my/message-line.png',
						text: '联系客服'
					},
					{
						icon: '/static/my/empathize-line.png',
						text: '关于我们'
					}
				]
			}
		}
	}
</script>

<style>
	.container {
		padding: 32rpx;
	}

	.user-info {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin: 30rpx 0 50rpx;
	}

	.avatar {
		width: 160rpx;
		height: 160rpx;
		border-radius: 50%;
		object-fit: contain;
	}

	.info {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 12rpx;
	}

	.nickname {
		font-size: 30rpx;
		font-weight: bold;
		color: #222;
		margin: 20rpx 0 14rpx;
	}

	.id {
		font-size: 24rpx;
		color: #666666;
		margin-right: 18rpx;
	}

	.tag {
		font-size: 20rpx;
		color: #fff;
		padding: 4rpx 16rpx;
		border-radius: 20rpx;
	}

	.menu-item {
		background: #fff;
		display: flex;
		align-items: center;
		padding: 30rpx 20rpx;
		margin-top: 24rpx;
		border-radius: 16rpx;
		text-align: left;
		line-height: unset;
	}

	.menu-item::after {
		border-style: none;
	}

	.menu-item image {
		width: 40rpx;
		height: 40rpx;
	}

	.menu-item text {
		flex: 1;
		margin-left: 20rpx;
		font-size: 26rpx;
		font-weight: 600;
		color: #222;
	}

	.arrow {
		width: 30rpx;
		height: 30rpx;
	}
</style>